//
//  DLJsBridgeBasePlugin.m
//  IBOSSSDK
//
//  Created by dgg_hzk on 2019/4/3.
//  Copyright © 2019年 apple. All rights reserved.
//

/*
 JS方法名
 */
//弹出一个加载框
static NSString *kDL_ShowLoadingTip = @"dgg_showLoadingTip";
//隐藏弹出框
static NSString *kDL_HideTip = @"dgg_hideTip";
//弹出一个成功模式的框
static NSString *kDL_SuccessfulTip = @"dgg_successfulTip";
//弹出一个错误模式的框
static NSString *kDL_ErrorTip = @"dgg_errorTip";
//弹出一个文字模式的框
static NSString *kDL_TextTip = @"dgg_textTip";
//储存一条字符串数据
static NSString *kDL_SaveText = @"dgg_saveText";
//查询一条字符串数据
static NSString *kDL_QueryText = @"dgg_queryText";
//删除一条字符串数据
static NSString *kDL_RemoveText = @"dgg_removeText";
//返回上一页
static NSString *kDL_PopVC = @"dgg_popvc";
//显示tabBar
static NSString *kDL_ShowTabBar = @"dgg_showTabBar";
//隐藏TabBar
static NSString *kDL_HideTabBar = @"dgg_hideTabBar";
//发起一个POST请求
static NSString *kDL_PostRequest = @"postRequest";
//发起一个GET请求
static NSString *kDL_GetRequest = @"getRequest";
//拨打电话
static NSString *kDL_CallPhone = @"callPhone";
//创建导航右侧按钮
static NSString *kDL_CreateRightBarItem = @"dgg_createRightBarItem";
//删除导航右侧按钮
static NSString *kDL_RemoveRightBarItem = @"dgg_removeRightBarItem";
//取消下拉刷新事件
static NSString *kDL_CancelPullRefresh = @"dgg_cancelPullRefresh";
//设置导航标题
static NSString *kDL_ChangeNavTitle = @"dgg_changeNavTitle";
//WebView返回事件
static NSString *kDL_WebGoBack = @"dgg_webGoBack";
//弹出确认框
static NSString *kDL_ShowAlertView = @"dgg_showAlertView";
//弹出选择框
static NSString *kDL_ShowActionSheet = @"dgg_showActionSheet";
//隐藏选择框
static NSString *kDL_DisMissActionSheet = @"dgg_disMissActionSheet";

#import "DLJsBridgeBasePlugin.h"
#import <WebKit/WebKit.h>
#import <DGGWebBridge/NSObject+DGGBridge.h>
#import <DGGWebBridge/WKWebViewJavascriptBridge.h>
#import <DGGUIKit/DGGUIKitPrefixHeader.h>
#import "DLEdgeInsetsButton.h"
#import "TipTool.h"
#import "DLPhoneAndMsgUtils.h"
#import <MJRefresh/MJRefresh.h>

@implementation DLJsBridgeBasePlugin

- (void)injectBaseHandleMethod{
    [super injectBaseHandleMethod];
    [self resterBridgeHandle];
}

- (NSString *)tableViewKeyName{
    unsigned  int count = 0;
    Ivar *members = class_copyIvarList([[self needRefreshController] class], &count);
    NSString *keyName = @"";
    NSInteger c = 0 ;
    for (int i = 0; i < count; i++){
        Ivar var = members[i];
        NSString * key = [NSString stringWithUTF8String:ivar_getName(var)];
        NSString * type = [NSString stringWithUTF8String:ivar_getTypeEncoding(var)];
        if ([type isEqualToString:@"@\"UITableView\""]) {
            c += 1;
            keyName = key;
        }
    }
    if (c<=1) {
        return keyName;
    }else{
        return keyName;
    }
}

- (NSMutableArray *)dataArray{
    if(!_dataArray){
        _dataArray = @[].mutableCopy;
    }
    return _dataArray;
}

- (NSMutableArray *)resultArray{
    if(!_resultArray){
        _resultArray = @[].mutableCopy;
    }
    return _resultArray;
}

- (void)resterBridgeHandle{
    //这里注册基础的交互事件
    [self dgg_showLoadingTip];//弹出一个加载框
    [self dgg_hideTip];//隐藏所有加载框
    [self dgg_successfulTip];//成功模式的提示框
    [self dgg_errorTip];//错误模式的提示框
    [self dgg_textTip];//文本模式的提示框
    [self dgg_saveText];//向本地储存一条数据
    [self dgg_queryText];//向本地查询一条数据
    [self dgg_removeText];//删除一条本地数据
    [self dgg_popvc];//返回上一界面
    [self dgg_showTabBar];//显示TabBar
    [self dgg_hideTabBar];//隐藏TabBar
    [self dgg_createRightBarItem];//创建导航栏右侧按钮
    [self dgg_removeRightBarItem];//删除导航右侧按钮
    [self registerCallPhoneHandler];//拨打电话
    [self dgg_cancelPullRefresh];//取消下拉刷新事件
    [self dgg_changeNavTitle];//设置导航标题
    [self dgg_webGoBack];//WebView返回事件
    
    [self dgg_showAlertView];
//    [self dgg_showMyActionSheet];
    [self dgg_disMissMyActionSheet];
}

//#pragma mark - 调用单选控件
//- (void)showSheetWith

#pragma mark - WebView返回事件
- (void)dgg_webGoBack
{
    kself
    [self.bridge registerHandler:kDL_WebGoBack handler:^(id data, WVJBResponseCallback responseCallback) {
        if ([weakSelf.bridgeWeb canGoBack]) {
            [weakSelf.bridgeWeb goBack];
            responseCallback(@{@"code":@"0",@"msg":@"返回成功"});
        } else {
            responseCallback(@{@"code":@"1",@"msg":@"不能返回,返回失败"});
        }
    }];
}

#pragma mark - 设置导航标题
- (void)dgg_changeNavTitle
{
    kself
    [self.bridge registerHandler:kDL_ChangeNavTitle handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"400",@"msg":@"参数不正确"});
        } else {
            if([data isKindOfClass:[NSDictionary class]]) {
                NSDictionary *dataDic = data;
                NSString *title = dataDic[@"title"];
                weakSelf.currentWebController.title = kFormat(title).isEmpty;
                responseCallback(@{@"code":@"0",@"msg":@"设置成功"});
            } else {
                responseCallback(@{@"code":@"1", @"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 取消下拉刷新事件
- (void)dgg_cancelPullRefresh
{
    kself
    [self.bridge registerHandler:kDL_CancelPullRefresh handler:^(id data, WVJBResponseCallback responseCallback) {
        weakSelf.bridgeWeb.scrollView.mj_header = nil;
        responseCallback(@{@"code":@"1", @"msg":@"取消下拉刷新成功"});
    }];
}

#pragma mark - 创建导航栏右侧按钮
- (void)dgg_createRightBarItem
{
    kself;
    [self.bridge registerHandler:kDL_CreateRightBarItem handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        } else {
            if([data isKindOfClass:[NSDictionary class]]) {
                NSDictionary *dataDic = data;
                NSString *title = dataDic[@"title"];
                NSString *img = dataDic[@"img"];
                DLButtonEdgeInsetsStyle imgLocation = [dataDic[@"imglocation"] integerValue];
                NSString *functionName = dataDic[@"functionName"];
                if ([NSString isEmpty:title] && [NSString isEmpty:img]) {
                    responseCallback(@{@"code":@"1",@"msg":@"文字和图标均为空"});
                } else if ([NSString isEmpty:functionName]) {
                    responseCallback(@{@"code":@"1",@"msg":@"回调方法名为空"});
                } else {
                    [weakSelf addRightBarItemWithTitle:title imgUrlStr:img style:imgLocation functionName:functionName];
                    responseCallback(@{@"code":@"0",@"msg":@"创建成功"});
                }
            } else {
                responseCallback(@{@"code":@"1", @"msg":@"参数不正确"});
            }
        }
    }];
}

- (void)addRightBarItemWithTitle:(NSString *)title imgUrlStr:(NSString *)imgUrlStr style:(DLButtonEdgeInsetsStyle)style functionName:(NSString *)functionName
{
    DLEdgeInsetsButton *barBtn = [DLEdgeInsetsButton buttonWithType:UIButtonTypeCustom];
    CGFloat btnWidth = 10;
    if (![NSString isEmpty:title]) {
        [barBtn setTitle:title forState:UIControlStateNormal];
        btnWidth += [title getWidthWithFontSize:barBtn.titleLabel.font.pointSize hight:44];
    }
    if (![NSString isEmpty:imgUrlStr]) {//如果imgUrlStr可以在自己的JsBridgePlugin重新实现创建右边按钮
//        [barBtn sd_setImageWithURL:[NSURL URLWithString:imgUrlStr] forState:UIControlStateNormal];
//        btnWidth += 30;
    }
    barBtn.bounds = CGRectMake(0, 0, btnWidth, 44);
    @weakify(self);
    [[[barBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
        @strongify(self);
        [self.bridge callHandler:functionName];
    }];
    self.currentWebController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:barBtn];
    barBtn.edgeInsetsStyle = style;
    barBtn.imageTitleSpace = 5;
}

#pragma mark - 删除导航右侧按钮
- (void)dgg_removeRightBarItem
{
    kself
    [self.bridge registerHandler:kDL_RemoveRightBarItem handler:^(id data, WVJBResponseCallback responseCallback) {
        weakSelf.currentWebController.navigationItem.rightBarButtonItem = nil;
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

#pragma mark - registerCallPhoneHandler
- (void)registerCallPhoneHandler{
    [self.bridge registerHandler:kDL_CallPhone handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if([data isKindOfClass:[NSDictionary class]]) {
                NSMutableDictionary *params = data;
                NSString *phone = params[@"phone"];
                if(![NSString isEmpty:phone]){
                    [DLPhoneAndMsgUtils callWithPhone:phone];
                    responseCallback(@{@"code":@"0",@"msg":@"拨打电话成功"});
                }else{
                    responseCallback(@{@"code":@"1",@"msg":@"电话号码格式不正确"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 弹出一个加载框 -
- (void)dgg_showLoadingTip{
    kself
    [self.bridge registerHandler:kDL_ShowLoadingTip handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            [TipTool showLodingTipsuperView:weakSelf.bridgeWeb];
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *msg = kFormat(data[@"msg"]);
                if ([NSString isEmpty:msg]) {
                    [TipTool showLodingTipsuperView:weakSelf.bridgeWeb];
                }else{
                    [TipTool showLodingTip:msg superView:weakSelf.bridgeWeb];
                }
            }else{
                [TipTool showLodingTipsuperView:weakSelf.bridgeWeb];
            }
        }
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

#pragma mark - 隐藏所有加载框 -
- (void)dgg_hideTip{
    [self.bridge registerHandler:kDL_HideTip handler:^(id data, WVJBResponseCallback responseCallback) {
        [TipTool hideTipView];
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

#pragma mark - 弹出一个成功模式的提示框 -
- (void)dgg_successfulTip{
    kself
    [self.bridge registerHandler:kDL_SuccessfulTip handler:^(id data, WVJBResponseCallback responseCallback) {
        [TipTool hideTipView];
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *msg = kFormat(data[@"msg"]);
                if ([NSString isEmpty:msg]) {
                    responseCallback(@{@"code":@"1",@"msg":@"操作失败"});
                }else{
                    [TipTool showMasSuccessfulTip:msg superView:weakSelf.bridgeWeb];
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
        
        
    }];
}
#pragma mark - 弹出一个错误模式的提示框 -
-(void)dgg_errorTip{
    kself
    [self.bridge registerHandler:kDL_ErrorTip handler:^(id data, WVJBResponseCallback responseCallback) {
        [TipTool hideTipView];
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *msg = kFormat(data[@"msg"]);
                if ([NSString isEmpty:msg]) {
                    responseCallback(@{@"code":@"1",@"msg":@"操作失败"});
                }else
                {
                    [TipTool showMasErrorTip:msg superView:weakSelf.bridgeWeb];
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 弹出一个文本模式的提示框 -
- (void)dgg_textTip{
    kself
    [self.bridge registerHandler:kDL_TextTip handler:^(id data, WVJBResponseCallback responseCallback) {
        [TipTool hideTipView];
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *msg = kFormat(data[@"msg"]);
                if ([NSString isEmpty:msg]) {
                    responseCallback(@{@"code":@"1",@"msg":@"操作失败"});
                }else{
                    [TipTool showMasTip:msg superView:weakSelf.bridgeWeb];
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 储存一条数据 -
- (void)dgg_saveText{
    [self.bridge registerHandler:kDL_SaveText handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *key = kFormat(data[@"key"]);
                NSString *value = kFormat(data[@"value"]);
                if ([NSString isEmpty:key]||[NSString isEmpty:value]) {
                    responseCallback(@{@"code":@"1",@"msg":@"操作失败"});
                }else{
                    [DGGUserDefaults saveWithObj:value forKey:key];
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 查询一条iOS 客户端本地数据 -
- (void)dgg_queryText{
    [self.bridge registerHandler:kDL_QueryText handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *key = kFormat(data[@"key"]);
                
                if ([NSString isEmpty:key]) {
                    responseCallback(@{@"code":@"0",@"data":@"",@"msg":@"操作成功"});
                }else{
                    NSString *value =  [DGGUserDefaults queryWithKey:key];
                    if ([NSString isEmpty:value]) {
                        responseCallback(@{@"code":@"0",@"data":@"",@"msg":@"操作成功"});
                    }else{
                        responseCallback(@{@"code":@"0",@"data":value,@"msg":@"操作成功"});
                    }
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 删除一条数据 -
- (void)dgg_removeText{
    [self.bridge registerHandler:kDL_RemoveText handler:^(id data, WVJBResponseCallback responseCallback) {
        if (!data) {
            responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
        }else{
            if ([data isKindOfClass:[NSDictionary class]]) {
                NSString *key = kFormat(data[@"key"]);
                if ([NSString isEmpty:key]) {
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }else{
                    [DGGUserDefaults removeWithKey:key];
                    responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
                }
            }else{
                responseCallback(@{@"code":@"1",@"msg":@"参数不正确"});
            }
        }
    }];
}

#pragma mark - 返回上一页 -
- (void)dgg_popvc{
    kself
    [self.bridge registerHandler:kDL_PopVC handler:^(id data, WVJBResponseCallback responseCallback) {
        [weakSelf.currentWebController.navigationController popViewControllerAnimated:YES];
        [weakSelf.currentWebController dismissViewControllerAnimated:YES completion:nil];
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

- (void)dgg_showTabBar{
    kself
    [self.bridge registerHandler:kDL_ShowTabBar handler:^(id data, WVJBResponseCallback responseCallback) {
        weakSelf.currentWebController.tabBarController.tabBar.hidden = NO;
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

- (void)dgg_hideTabBar{
    kself
    [self.bridge registerHandler:kDL_HideTabBar handler:^(id data, WVJBResponseCallback responseCallback) {
        weakSelf.currentWebController.tabBarController.tabBar.hidden = YES;
        responseCallback(@{@"code":@"0",@"msg":@"操作成功"});
    }];
}

- (void)dgg_showAlertView{
    [self.bridge registerHandler:kDL_ShowAlertView handler:^(id data, WVJBResponseCallback responseCallback) {
        if(!data || data == [NSNull null] || ![data isKindOfClass:[NSDictionary class]]){
            responseCallback(@{@"code":@"1",@"msg":@"参数错误"});
            return;
        }
        NSString *title = kFormat(data[@"title"]).isEmpty;
        NSString *message = kFormat(data[@"message"]).isEmpty;
        NSArray *buttons = data[@"buttons"];
        NSArray *placeholders = data[@"placeholders"];
        NSString *type = kFormat(data[@"type"]).isEmpty;
        if(buttons == nil || ![buttons isKindOfClass:([NSArray class])]){
            buttons = @[@"确定"];
        }
        if(placeholders == nil || ![placeholders isKindOfClass:([NSArray class])]){
            placeholders = nil;
        }
        if ([type.lowercaseString isEqualToString:@"actionsheet"]){
            [TipTool showiPhoneSheetViewWithTitle:title message:message btns:buttons block:^(NSInteger index) {
                NSDictionary *resultDC = @{@"code":@"0",@"msg":@"操作成功",@"index":@(index)};
                responseCallback(resultDC);
            }];
        }else if([type.lowercaseString isEqualToString:@"alerttextfield"]){
            [TipTool showAlertTextFieldViewWithTitle:title message:message btns:buttons placeholders:placeholders block:^(NSInteger index, NSArray *texts) {
                NSDictionary *resultDC = @{@"code":@"0",@"msg":@"操作成功",@"index":@(index),@"data":texts};
                responseCallback(resultDC);
            }];
        }else{
            //默认alert
            [TipTool showAlertViewWithTitle:title message:message btns:buttons block:^(NSInteger index) {
                NSDictionary *resultDC = @{@"code":@"0",@"msg":@"操作成功",@"index":@(index)};
                responseCallback(resultDC);
            }];
        }
    }];
}

//- (void)dgg_showMyActionSheet{
//    [self.bridge registerHandler:kDL_ShowActionSheet handler:^(id data, WVJBResponseCallback responseCallback) {
//        if(!data || data == [NSNull null] || ![data isKindOfClass:[NSDictionary class]]){
//            responseCallback(@{@"code":@"1",@"msg":@"参数错误"});
//            return;
//        }
//        NSString *type = kFormat(data[@"type"]).isEmpty;
//        NSMutableDictionary *resultDC = @{@"code":@"0",@"msg":@"操作成功"}.mutableCopy;
//        if(![NSString isEmpty:type]){
//            MyActionSheet *myActionSheet = nil;
//            NSString *chooseName = nil;
//            if(![NSString isEmpty:data[@"chooseName"]]){
//                chooseName = kFormat(data[@"chooseName"]).isEmpty;
//            }
//            if([type isEqualToString:@"0"]){
//                //自定义ActionSheet
//                NSString *title = kFormat(data[@"title"]).isEmpty;
//                NSString *selectType = kFormat(data[@"selectType"]).isEmpty;
//                NSArray *nameArray = data[@"nameArray"];
//                if([selectType isEqualToString:@"1"]){
//                    NSString *colorName = kFormat(data[@"color"]).isEmpty;
//                    if([NSString isEmpty:colorName]){
//                        colorName = @"#999999";
//                    }
//                    //多选
//                    if([NSString isEmpty:data[@"maxCount"]]){
//                        //多选不限制
//                        myActionSheet = [[MyActionSheet alloc] initWithNameArray:nameArray title:title selectedCellColor:[UIColor colorWithHexString:colorName] multididSelectedBlock:^(NSArray *indexs) {
//                            [resultDC setValue:indexs forKey:@"indexs"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }else{
//                        //多选限制
//                        NSInteger maxCount = [kFormat(data[@"maxCount"]).isEmpty integerValue];
//                        myActionSheet = [[MyActionSheet alloc] initWithNameArray:nameArray title:title maxCount:maxCount selectedCellColor:[UIColor colorWithHexString:colorName] multididSelectedBlock:^(NSArray *indexs) {
//                            [resultDC setValue:indexs forKey:@"indexs"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }
//                }else{
//                    //单选
//                    BOOL isRecored = [kFormat(data[@"isRecored"]).isEmpty boolValue];
//                    if(![NSString isEmpty:data[@"canClear"]]){
//                        BOOL canClear = [kFormat(data[@"canClear"]).isEmpty boolValue];
//                        if(![NSString isEmpty:data[@"align"]] && [kFormat(data[@"align"]).isEmpty isEqualToString:@"1"]){
//                            myActionSheet = [[MyActionSheet alloc] initCenterShowWithNameArray:nameArray title:title isRecored:isRecored canClear:canClear didSelectedBlock:^(NSInteger index) {
//                                [resultDC setValue:@(index) forKey:@"index"];
//                                responseCallback(resultDC);
//                            }];
//                            [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                        }else{
//                            myActionSheet = [[MyActionSheet alloc] initWithNameArray:nameArray title:title isRecored:isRecored canClear:canClear didSelectedBlock:^(NSInteger index) {
//                                [resultDC setValue:@(index) forKey:@"index"];
//                                responseCallback(resultDC);
//                            }];
//                            [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                        }
//                    }else{
//                        myActionSheet = [[MyActionSheet alloc] initWithNameArray:nameArray title:title isRecored:isRecored didSelectedBlock:^(NSInteger index) {
//                            [resultDC setValue:@(index) forKey:@"index"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }
//                }
//            }else if ([type isEqualToString:@"1"]){
//                //时间选择器
//                NSString *title = kFormat(data[@"title"]).isEmpty;
//                if([Helper isEmpty:data[@"dateStyle"]]){
//                    //样式为空
//                    if([Helper isEmpty:data[@"dateLimit"]]){
//                        //无限制
//                        myActionSheet = [[MyActionSheet alloc] initWithStartDate:nil title:title dateBlock:^(NSString *date) {
//                            [resultDC setValue:date forKey:@"date"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }else{
//                        //有限制，获取限制类型
//                        int dateLimit = [kFormat(data[@"dateLimit"]).isEmpty intValue];
//                        NSString *limitDate = nil;
//                        if(dateLimit == 1){
//                            //获取最大时间
//                            limitDate = kFormat(data[@"maxLimitDate"]).isEmpty;
//                        }else if (dateLimit == 2){
//                            //获取最小时间
//                            limitDate = kFormat(data[@"minLimitDate"]).isEmpty;
//                        }
//                        if(![Helper isEmpty:limitDate]){
//                            limitDate = [[limitDate componentsSeparatedByString:@" "] firstObject];
//                        }
//                        myActionSheet = [[MyActionSheet alloc] initWithStartDate:limitDate title:title dateLimit:dateLimit dateBlock:^(NSString *date) {
//                            [resultDC setValue:date forKey:@"date"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }
//                }else{
//                    int dateStyle = [kFormat(data[@"dateStyle"]).isEmpty intValue];
//                    NSDate *maxLimitDate = nil;
//                    if(![Helper isEmpty:data[@"maxLimitDate"]]){
//                        NSString *maxLimitDateStr = kFormat(data[@"maxLimitDate"]).isEmpty;
//                        maxLimitDate = [Helper getDateFormat:@"yyyy-MM-dd HH:mm:ss" dataStr:maxLimitDateStr];
//                    }
//                    NSDate *minLimitDate = nil;
//                    if(![Helper isEmpty:data[@"minLimitDate"]]){
//                        NSString *minLimitDateStr = kFormat(data[@"minLimitDate"]).isEmpty;
//                        minLimitDate = [Helper getDateFormat:@"yyyy-MM-dd HH:mm:ss" dataStr:minLimitDateStr];
//                    }
//                    NSDate *scrollToDate = nil;
//                    if(![Helper isEmpty:data[@"scrollToDate"]]){
//                        NSString *scrollToDateStr = kFormat(data[@"scrollToDate"]).isEmpty;
//                        scrollToDate = [Helper getDateFormat:@"yyyy-MM-dd HH:mm:ss" dataStr:scrollToDateStr];
//                    }
//                    if(![Helper isEmpty:data[@"canClear"]]){
//                        BOOL canClear = [kFormat(data[@"canClear"]).isEmpty boolValue];
//                        myActionSheet = [[MyActionSheet alloc] initWithDateStyle:dateStyle title:title MaxLimitDate:maxLimitDate minLimitDate:minLimitDate scrollToDate:scrollToDate canClear:canClear dateBlock:^(NSString *date) {
//                            [resultDC setValue:date forKey:@"date"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }else{
//                        myActionSheet = [[MyActionSheet alloc] initWithDateStyle:dateStyle title:title MaxLimitDate:maxLimitDate minLimitDate:minLimitDate scrollToDate:scrollToDate dateBlock:^(NSString *date) {
//                            [resultDC setValue:date forKey:@"date"];
//                            responseCallback(resultDC);
//                        }];
//                        [myActionSheet showInView:KMyWindow chooseName:chooseName];
//                    }
//                }
//            }
//        }else{
//            NSLog(@"___类型为空");
//            [resultDC setValue:@"类型为空" forKey:@"msg"];
//            [resultDC setValue:@"1" forKey:@"code"];
//            responseCallback(resultDC);
//        }
//    }];
//}

- (void)dgg_disMissMyActionSheet{
    [self.bridge registerHandler:kDL_DisMissActionSheet handler:^(id data, WVJBResponseCallback responseCallback) {
        [TipTool hideTipView];
        NSDictionary *resultDC = @{@"code":@"0",@"msg":@"操作成功"};
        responseCallback(resultDC);
    }];
}

@end
